package com.heima.common.exception;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import lombok.extern.log4j.Log4j2;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@ControllerAdvice
@Log4j2
public class ExceptionCatch {

    @ExceptionHandler(Exception.class)
    public ResponseResult exception(Exception e){

        e.printStackTrace();
        //错误信息保存到日志
        log.error("catch exception:{}", e.getMessage());

      //  return new ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
        return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR);
    }

}
